package com.jwell.panrank.model

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.panrank.application.App
import com.jwell.panrank.contract.WaybillInfoContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by 76577 on 2018/6/11.
 */
class WaybillInfoModel : WaybillInfoContract.Model, BaseModel() {

    override fun getData(id: Int, baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("根据运单Id获取详情" + id)
        val map = mutableMapOf("id" to id)
        getApiStore().getForExportWaybillById(map)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun revokeWaybill(id: Int, baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("撤销" + id)
        val map = mutableMapOf("id" to id)
        getApiStore().revokeWaybill(map)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun applyDelay(id: Int, baseSubscriber: BaseSubscriber) {
        if (App.DEBUG) println("申请延期" + id)
        val map = mutableMapOf("id" to id)
//        getApiStore().applyDelay(map)
//                .subscribeOn(Schedulers.io())
//                .unsubscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(baseSubscriber)
    }
}